package com.cssy.xxkj.logic.dao.impl;

import java.util.List;
import java.util.Map;

import org.springframework.dao.DataAccessException;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.cssy.xxkj.logic.dao.LogicCheckBackItemDAO;
import com.cssy.xxkj.logic.entity.LogicCheckBackItemDO;

/**
 * 数据访问对象实现类
 * @since 2014-11-12
 */
public class LogicCheckBackItemDAOImpl extends SqlMapClientDaoSupport implements LogicCheckBackItemDAO {

    /**
     * 插入数据
     * @param logicCheckBackItemDO
     * @return 插入数据的主键
     */
    public String insertLogicCheckBackItemDO(LogicCheckBackItemDO logicCheckBackItemDO) throws DataAccessException {
        Object id = getSqlMapClientTemplate().insert("LogicCheckBackItem.insert", logicCheckBackItemDO);
        return (String) id;
    }

    /**
     * 统计记录数
     * @param logicCheckBackItemDO
     * @return 查出的记录数
     */
    public Integer countLogicCheckBackItemDOByExample(LogicCheckBackItemDO logicCheckBackItemDO) throws DataAccessException {
        Integer count = (Integer) getSqlMapClientTemplate().queryForObject("LogicCheckBackItem.countByDOExample", logicCheckBackItemDO);
        return count;
    }

    /**
     * 更新记录
     * @param logicCheckBackItemDO
     * @return 受影响的行数
     */
    public Integer updateLogicCheckBackItemDO(LogicCheckBackItemDO logicCheckBackItemDO) throws DataAccessException {
        int result = getSqlMapClientTemplate().update("LogicCheckBackItem.update", logicCheckBackItemDO);
        return result;
    }

    /**
     * 获取对象列表
     * @param logicCheckBackItemDO
     * @return 对象列表
     */
    @SuppressWarnings("unchecked")
    public List<LogicCheckBackItemDO> findListByExample(LogicCheckBackItemDO logicCheckBackItemDO) throws DataAccessException {
        List<LogicCheckBackItemDO> list = getSqlMapClientTemplate().queryForList("LogicCheckBackItem.findListByDO", logicCheckBackItemDO);
        return list;
    }
    
    public List<LogicCheckBackItemDO> findListByMap(Map<String, Object> paramMap) throws DataAccessException{
    	List<LogicCheckBackItemDO> list = getSqlMapClientTemplate().queryForList("LogicCheckBackItem_ex.findListByMap", paramMap);
        return list;
    }

    /**
     * 根据主键获取logicCheckBackItemDO
     * @param id
     * @return logicCheckBackItemDO
     */
    public LogicCheckBackItemDO findLogicCheckBackItemDOByPrimaryKey(String id) throws DataAccessException {
        LogicCheckBackItemDO logicCheckBackItemDO = (LogicCheckBackItemDO) getSqlMapClientTemplate().queryForObject("LogicCheckBackItem.findByPrimaryKey", id);
        return logicCheckBackItemDO;
    }

    /**
     * 删除记录
     * @param id
     * @return 受影响的行数
     */
    public Integer deleteLogicCheckBackItemDOByPrimaryKey(String id) throws DataAccessException {
        Integer rows = (Integer) getSqlMapClientTemplate().delete("LogicCheckBackItem.deleteByPrimaryKey", id);
        return rows;
    }

	@Override
	public Integer deleteLogicCheckBackItemDOByLogicCheckBackId(String id)
			throws DataAccessException {
		Integer rows = (Integer) getSqlMapClientTemplate().delete("LogicCheckBackItem_ex.deleteByCheckBackId", id);
		return rows;
	}

}